home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
TECHNICA
/
COMPUTER
/
H254.ZIP
/
IRITSM3S.ZIP
/
IRIT
/
PLATONIC.IRT
< prev
next >
Wrap
Text File
|
1991-12-15
|
4KB
|
156 lines
#
# Constructs the five Platonic Solids.
#
# Gershon Elber Dec. 1991.
#
g = (sqrt( 5 ) + 1) / 2; # The golden ratio
q = g - 1;
normal(1,0.2,yellow);
#
# Tetrahedron
#
v1 = vector( 1, 1, 1 );
v2 = vector( 1, -1, -1 );
v3 = vector( -1, 1, -1 );
v4 = vector( -1, -1, 1 );
pl1 = poly( list( v1, v3, v2 ) );
pl2 = poly( list( v1, v4, v3 ) );
pl3 = poly( list( v1, v2, v4 ) );
pl4 = poly( list( v2, v3, v4 ) );
tetra = mergepoly( list( pl1, pl2, pl3, pl4 ) );
interact( tetra, false );
#
# Cube
#
v1 = vector( -1, -1, -1 );
v2 = vector( -1, -1, 1 );
v3 = vector( -1, 1, 1 );
v4 = vector( -1, 1, -1 );
v5 = vector( 1, -1, -1 );
v6 = vector( 1, -1, 1 );
v7 = vector( 1, 1, 1 );
v8 = vector( 1, 1, -1 );
pl1 = poly( list( v4, v3, v2, v1 ) );
pl2 = poly( list( v5, v6, v7, v8 ) );
pl3 = poly( list( v1, v2, v6, v5 ) );
pl4 = poly( list( v2, v3, v7, v6 ) );
pl5 = poly( list( v3, v4, v8, v7 ) );
pl6 = poly( list( v4, v1, v5, v8 ) );
cube = mergepoly( list( pl1, pl2, pl3, pl4, pl5, pl6 ) );
interact( cube, false );
#
# Octahedron
#
v1 = vector( 0, 0, 1 );
v2 = vector( 1, 0, 0 );
v3 = vector( 0, 1, 0 );
v4 = vector( -1, 0, 0 );
v5 = vector( 0, -1, 0 );
v6 = vector( 0, 0, -1 );
pl1 = poly( list( v1, v3, v2 ) );
pl2 = poly( list( v1, v4, v3 ) );
pl3 = poly( list( v1, v5, v4 ) );
pl4 = poly( list( v1, v2, v5 ) );
pl5 = poly( list( v6, v2, v3 ) );
pl6 = poly( list( v6, v3, v4 ) );
pl7 = poly( list( v6, v4, v5 ) );
pl8 = poly( list( v6, v5, v2 ) );
octa = mergepoly( list( pl1, pl2, pl3, pl4, pl5, pl6, pl7, pl8 ) );
interact( octa, false );
#
# Dodecahedron
#
v1 = vector( 0, q, g );
v2 = vector( 0, -q, g );
v3 = vector( 1, 1, 1 );
v4 = vector( 1, -1, 1 );
v5 = vector( -1, -1, 1 );
v6 = vector( -1, 1, 1 );
v7 = vector( -g, 0, q );
v8 = vector( g, 0, q );
v9 = vector( q, g, 0 );
v10 = vector( -q, g, 0 );
v11 = vector( -q, -g, 0 );
v12 = vector( q, -g, 0 );
v13 = vector( -g, 0, -q );
v14 = vector( g, 0, -q );
v15 = vector( 1, 1, -1 );
v16 = vector( -1, 1, -1 );
v17 = vector( -1, -1, -1 );
v18 = vector( 1, -1, -1 );
v19 = vector( 0, q, -g );
v20 = vector( 0, -q, -g );
pl1 = poly( list( v2, v1, v3, v8, v4 ) );
pl2 = poly( list( v1, v2, v5, v7, v6 ) );
pl3 = poly( list( v1, v3, v9, v10, v6 ) );
pl3 = poly( list( v6, v10, v9, v3, v1 ) );
pl4 = poly( list( v2, v4, v12, v11, v5 ) );
pl5 = poly( list( v4, v8, v14, v18, v12 ) );
pl6 = poly( list( v5, v7, v13, v17, v11 ) );
pl6 = poly( list( v11, v17, v13, v7, v5 ) );
pl7 = poly( list( v13, v16, v10, v6, v7 ) );
pl8 = poly( list( v16, v19, v15, v9, v10 ) );
pl9 = poly( list( v3, v9, v15, v14, v8 ) );
pl10 = poly( list( v14, v15, v19, v20, v18 ) );
pl11 = poly( list( v12, v18, v20, v17, v11 ) );
pl12 = poly( list( v17, v13, v16, v19, v20 ) );
pl12 = poly( list( v20, v19, v16, v13, v17 ) );
dodeca = mergepoly( list( pl1, pl2, pl3, pl4, pl5, pl6,
pl7, pl8, pl9, pl10, pl11, pl12 ) );
interact( dodeca, false );
#
# Icosahedron (Note we construct only its upper half and reflect it).
#
v1 = vector( 1, 0, g );
v2 = vector( -1, 0, g );
v3 = vector( 0, g, 1 );
v4 = vector( 0, -g, 1 );
v5 = vector( g, 1, 0 );
v6 = vector( -g, 1, 0 );
v7 = vector( -g, -1, 0 );
v8 = vector( g, -1, 0 );
v9 = vector( 0, g, -1 );
pl1 = poly( list( v2, v3, v1 ) );
pl2 = poly( list( v1, v4, v2 ) );
pl3 = poly( list( v2, v6, v3 ) );
pl4 = poly( list( v3, v5, v1 ) );
pl5 = poly( list( v3, v9, v5 ) );
pl6 = poly( list( v3, v6, v9 ) );
pl7 = poly( list( v2, v7, v6 ) );
pl8 = poly( list( v2, v4, v7 ) );
pl9 = poly( list( v1, v8, v4 ) );
pl10 = poly( list( v1, v5, v8 ) );
icosa1 = mergepoly( list( pl1, pl2, pl3, pl4, pl5, pl6, pl7, pl8, pl9, pl10 ) );
icosa2 = icosa1 * rotx( 180 );
icosa = mergepoly( list( icosa1, icosa2 ) );
interact( icosa, false );